function [sum1,mi] = FullSearch_ABS_Angle(refImg,baseImg,senpt,l,magImg1,magImg2)
% tempCo1 = transferTo(tform,tempCo,H,tranFlag);
% %tranformed coordinate (X_Sen_c, Y_Sen_c)
% senpt_x = tempCo1(1);
% senpt_y = tempCo1(2);
% senpt_x1=round(tempCo1(1));
% senpt_y1 =round(tempCo1(2)); 
% for i=1:size(results,1)
%     for j=1:size(results,2)
        sum1=0;
   
        senpt2_x=senpt(1);
        senpt2_y=senpt(2);
        senseImg=baseImg(senpt2_y-floor(l/2):senpt2_y+floor(l/2),senpt2_x-floor(l/2):senpt2_x+floor(l/2));
        magImg2=magImg2(senpt2_y-floor(l/2):senpt2_y+floor(l/2),senpt2_x-floor(l/2):senpt2_x+floor(l/2));
hab = zeros(32,32);
ha = zeros(1,32);
hb = zeros(1,32);

%normalize


a = mat2gray(magImg1);
b = mat2gray(magImg2);

a = double(int16(a*255));
b = double(int16(b*255));

        for y=1:size(refImg,1)
            for x=1:size(refImg,2)
                sum1=sum1+abs(pi/2-abs(refImg(y,x)-senseImg(y,x)));
                sum1=sum1+exp(-abs(tan(abs(refImg(y,x)-senseImg(y,x)))).^2);
%                 sum1=sum1+exp(-(tan(abs(refImg(y,x)-senseImg(y,x)))).^2);
%                 sum1=sum1+cos(abs(refImg(y,x)-senseImg(y,x))).^2;
                indexx = floor(a(y,x)/8)+1 ;
                indexy = floor(b(y,x)/8)+1;
                hab(indexx,indexy) = hab(indexx,indexy)+1;%jiont histogram
                ha(indexx) = ha(indexx)+1; 
                hb(indexy) = hb(indexy)+1;
            end
        end
        hsum = sum(sum(hab));
index = find(hab~=0);
p = hab/hsum;
Hab = sum(sum(-p(index).*log(p(index))));

%calculate the entropy of a
hsum = sum(sum(ha));
index = find(ha~=0);
p = ha/hsum;
Ha = sum(sum(-p(index).*log(p(index))));

%calculate the entropy of b
hsum = sum(sum(hb));
index = find(hb~=0);
p = hb/hsum;
Hb = sum(sum(-p(index).*log(p(index))));

%calculate the MI of a and b
mi = Ha+Hb-Hab;
% mi = (Ha+Hb)/Hab;
end